<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header">
</head>

<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>请仔细填写</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="dropdown-toggle" data-toggle="dropdown" href="form_basic.html#">
                                <i class="fa fa-wrench"></i>
                            </a>
                            <ul class="dropdown-menu dropdown-user">
                                <li><a href="form_basic.html#">选项1</a>
                                </li>
                                <li><a href="form_basic.html#">选项2</a>
                                </li>
                            </ul>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <form class="form-horizontal m-t" name="recordsForm" id="recordsForm">
                        	<div class="form-group">
                                <label class="col-sm-3 control-label">预备党员备案记录：</label>
                                <div class="col-sm-8">
									<input id="prepareEvolveId" placeholder="" name="prepareEvolveId" class="form-control" type="text">
                                	<span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请选择会议所对应的备案记录</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">会议名称：</label>
                                <div class="col-sm-8">
                                    <input id="name" placeholder="" name="conferenceName" class="form-control valid" type="text" aria-required="true" aria-invalid="false">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">会议时间：</label>
                                <div class="col-sm-8">
                                    <input id="date" placeholder="" name="date" class="form-control valid" type="text" aria-required="true" aria-invalid="false">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">投票记录：</label>
                                <div class="col-sm-8">
                                    <input id="file" placeholder="" name="file" class="form-control required" accept='application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/msword' type="file">
                                	<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 会议产生的文件记录</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">决议通过对象：</label>
                                <div class="col-sm-8">
		                            <input id="sList" placeholder="请先选择备案记录" name="sList" class="form-control required" type="text">
                                	<span class="help-block m-b-none"><i class="fa fa-info-circle"></i>只列出本次备案的对象</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">决议未通过对象：</label>
                                <div class="col-sm-8">
		                            <input id="fList" placeholder="请先选择备案记录" name="fList" class="form-control" type="text">
		                            <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 只要选择了“无”，一律视为空</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">会议内容：</label>
                                <div class="col-sm-8">
                                	<span class="help-block m-b-none"><i class="fa fa-info-circle">非必需填写</i> </span>
                                    <input name="contents" id="contents">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-8 col-sm-offset-5">
                                    <button class="btn btn-default" value="0" onclick="$.modal.close()">取消</button>&nbsp;&nbsp;
                                    <button class="btn btn-primary" >提交</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

    </div>
    <div th:include="include::footer"></div>
	<script th:src="@{/partyjoin/js/module/activistEvolve/add.js}"></script>
	<!-- 甜甜的弹出层 -->
<!--  	<script src="https://cdn.bootcss.com/limonte-sweetalert2/7.21.1/sweetalert2.all.js"></script> -->
	<script type="text/javascript">
		//初始化文件选择框
    	$('input[type="file"]').prettyFile();
    	//时间选择初始化
        $("#date").datepicker({
        	format: 'yyyy-mm-dd',
        	language: 'cn',
        });
        //初始化富文本框
		$('#contents').summernote({ 
               lang: 'zh-CN',
               height: 100           
             });
        
        var url = '/module/prepareEvolve/selectUserByPrepareEvolveId'; 
        
        //初始化备案记录下拉选择框
	    $('#prepareEvolveId').magicSuggest({
			allowFreeEntries: false,//允许用户输入非建议条目的数据
			allowDuplicates: false,//允许用户多次输入重复的条目
			autoSelect: false,//如果只找到一个匹配项，则自动选择结果。
			maxSelection: 20,//设置可以选择的项的限制
			noSuggestionText: "未查询到相关信息",//当未找到匹配项时显示的文本
			data: '/module/prepareEvolve/selectPrepareEvolveToConference',
			required: true,//必须
			dataUrlParams: {},
			toggleOnClick: true,//单击打开
			useZebraStyle: true,//突显奇数行
			beforeSend: function(){
			},
			selectionRenderer: function(data){//定义如何显示所选项。
				//根据选择的培养记录动态改变决议对象
				//初始化下拉选择框
			    $('#sList').magicSuggest({
					allowFreeEntries: false,//允许用户输入非建议条目的数据
					allowDuplicates: false,//允许用户多次输入重复的条目
					autoSelect: false,//如果只找到一个匹配项，则自动选择结果。
					maxSelection: 20,//设置可以选择的项的限制
					noSuggestionText: "未查询到相关信息",//当未找到匹配项时显示的文本
					data: url + '?prepareEvolveId=' + data.id,
					required: true,//必须
					dataUrlParams: {"type": "success"},
					toggleOnClick: true,//单击打开
					useZebraStyle: true,//突显奇数行
					beforeSend: function(){
					},
					selectionRenderer: function(data){//定义如何显示所选项。
						
						 return '<span style="color: orange"><strong> '+data.name+' </strong></span>' + ' (<b>身份证：' + data.idCardNo + '</b>)';
					},
					method: "GET"
				});	
				
				//初始化下拉框
				$('#fList').magicSuggest({
				allowFreeEntries: false,//允许用户输入非建议条目的数据
				allowDuplicates: false,//允许用户多次输入重复的条目
				autoSelect: false,//如果只找到一个匹配项，则自动选择结果。
				maxSelection: 20,//设置可以选择的项的限制
				noSuggestionText: "未查询到相关信息",//当未找到匹配项时显示的文本
				data: url + '?prepareEvolveId=' + data.id,
				required: true,//必须
				dataUrlParams: {"type": "fail"},
				toggleOnClick: true,//单击打开
				useZebraStyle: true,//突显奇数行
				selectionRenderer: function(data){//定义如何显示所选项。
					console.log(data)
					 return '<span style="color: orange"><strong> '+data.name+' </strong></span>' + ' (<b>身份证：' + data.idCardNo + '</b>)';
					},
					method: "GET"
				});
				
				 return '<span style="color: orange"><strong> '+data.name+' </strong></span>';

			},
			method: "GET"
		});	
        
       
		
        
        var prefix = "/module/conference"
		//表单验证
        $().ready(function () {
            //$("#commentForm").validate();
            var icon = "<i class='fa fa-times-circle'></i> ";
            $("#recordsForm").validate({
                rules: {
                	conferenceName: {
                		required: true,
                		rangelength: [5, 20],
                		remote: function(value){
                			console.log("检测会议名是否存在。待完善")
                		}
                	},
                	type: {
                		required: true
                	},
                	date: "required",
                	file: {
                		required: true,
                		accept: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/msword'
                	}
                },
                messages: {
                    conferenceName: icon + "会议名称在5~20字之间",
 					file: icon + "只能选择后缀为doc或docx的文件"
                },
                submitHandler: function(form) { 
                    var fileName = $("#file").val();
                    if(fileName == '<p><br></p>'){
                    	alert("文件空啦");
                    	return;
                    }
					var contents = $('#contents').code();
					console.log("ddd"+$('#prepareEvolveId').val());
			       	var forms = new FormData(document.getElementById('recordsForm'));
			       	forms.append("contents", contents);
					$.modal.loading("正在处理中，请稍后...");
					$.ajax({
						url : '/module/conference/savePrepare',
						type : "post",
						dataType : "json",
						data : forms,
						processData: false,
						contentType: false,
						success : function(result) {
							$.operate.saveSuccess(result)
						}
					});
				}
       	});
       	});
        

	</script>
	<script>
	function submit(){
	

					
    	}
	</script>
</body>
</html>
